//
//  BaseViewController.swift
//  rdb-led-banner
//
//  Created by radiobox3 on 2025/4/18.
//

import UIKit

class BaseViewController: UIViewController {
    
    var showBackButton: Bool = false{
        didSet{
            if showBackButton {
                self.navigationItem.hidesBackButton = true
                self.navigationItem.leftBarButtonItem = backItemBar
            }else{
                self.navigationItem.hidesBackButton = true
                self.navigationItem.leftBarButtonItem = nil
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    
    lazy var backItemBar: UIBarButtonItem = {
        let barItem = UIBarButtonItem(image: UIImage(named: "navigation_back")?.rtlImage().withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(backButtonAction))
        return barItem
    }()
    
    @objc func backButtonAction(){
        self.navigationController?.popViewController(animated: true)
    }

    override var shouldAutorotate: Bool{
        return false
    }
    
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
        return .portrait
    }

}
